package com.bzg.manager.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bzg.manager.bean.LinkInfo;
import com.bzg.manager.bean.PartInfo;
import com.bzg.manager.dao.PersonCenterMapper;
import com.bzg.manager.exception.BaseException;
import com.bzg.manager.exception.BaseExceptionTool;
import com.bzg.manager.param.BusiQueryParam;
import com.bzg.manager.param.UserParam;
import com.bzg.manager.service.PersonCenterService;
import com.bzg.manager.utils.PageBean;

@Service
public class PersonCenterServiceImpl implements PersonCenterService {
	
	public static final Logger log = LoggerFactory.getLogger(PersonCenterServiceImpl.class);
	
	@Autowired
	private PersonCenterMapper personCenterMapper;
	
	@Override
	public PageBean<PartInfo> getPartInfo(BusiQueryParam param) throws BaseException {
		//获取符合条件的总记录数
		Integer count = personCenterMapper.getPartInfoCount(param);
		List<PartInfo> partInfoList = new ArrayList<>();
		if(count != null && count > 0){
			//获取数据
			partInfoList = personCenterMapper.getPartInfoList(param);
		}
		PageBean<PartInfo> pageBean = new PageBean<>();
		
		pageBean.setTotalCount(count);
		pageBean.setDataList(partInfoList);
		return pageBean;
	}

	@Override
	public List<LinkInfo> getComLink(UserParam param) {
		if(param == null || StringUtils.isEmpty(param.getVendCode())){
			throw BaseExceptionTool.PARAM_IS_NULL;
		}
		return personCenterMapper.getCompLink(param);
	}

}
